Using Language Definitions
Description
Language definitions define the text to display in Language Tags for the active language.
Discussion
You can tag any text in the Component definition so that it becomes replaceable, depending on the selected language.
To tag text, you enclose it in <a5:r> and </a5:r> tags. For example, you might tag the heading for the Lastname column as:
<a5:r>Lastname</a5:r>
You can define as many language definitions as you want in the Language Definitions dialog.
Each language definition is a set of name=value pairs that do not include line breaks. For example, assume you have tagged the following strings in your Component definition:
<a5:r>First Name</a5:r> <a5:r>Last Name</a5:r> <a5:r>City</a5:r>
Your language definition for the <Default> language might be:
First Name=First Name Last Name=Last Name City=City
The language definition for French might be:
First Name=Prénom Last Name=Nom de Famille City=Ville
Using Expressions in the Replacement Strings
You can use expressions in the replacement strings by prefixing the expression with 'expn:'. For example, in the case of a Grid component, the language definition below uses expressions that reference a session variable and a variables that might have been defined in the OnGridInitialize event.
First Name=Prénom Last Name=Nom de Famille City=Ville Company=expn:session.companyName WelcomeMessage=expn:rtc._myvariables.welcomeMessage
Setting the Active Language
If you don't specify an active language, the <Default> language is assumed. To set the active language, you set the 'ActiveLanguage' property. You can set this property in the 'Override Settings' section in the .A5W page that loads the Grid, or in the Grid component's OnGridInitialize event.
For example, to set the ActiveLanguage in the OnGridInitialize event:
e.tmpl.ActiveLanguage = "French"
A second way to set the active language is by using the special protected session variable, session.__protected__activeLanguage. For example:
session.__protected__activeLanguage = "French"
If you set both the session.__protected__activeLanguage and the 'ActiveLanguage' property in Override Settings or OnGridInitialize, the session.__protected__activeLanguage property is honored.
Using External Language Definitions
You can pass in an external language definition to the Grid at run-time by setting the 'languageDefinition' property in Override Settings or the OnGridInitialize event. If you pass in an external language definition which defines a replacement value that is also defined in the language definition that is defined in the Grid itself, the external language definition will be used.
The example below shows how to define an external language definition. Note that 'Surname' and 'Postal Code' are literal values and =date() is an Xbasic expression.
tmpl.languageDefinition =<<%txt% <a5:r>lastname</a5:r>="Surname" <a5:r>zip</a5:r>="Postal Code" <a5:r>date</a5:r>=date() %txt%
Important Note About using Language Tags in Javascript Code
If you use language tags in Javascript code, the replacement string must be properly escaped in the definition file. For example:
Cancel=No, don\'t save image
URL Encoding Values
In some cases, you will want a language tag to return a URL encoded value. You do this by enclosing the value in a special tag -- urlEncode{{your text here}}. For example:
prompt=urlEncode{{Select the file to upload}}